<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>

    /*原型模式*/
    function Employee() {
    }

    /***
     * prototype ：原型
     * */
   /* Employee.prototype.name = "Martin";
    Employee.prototype.roles=['normal']; // 引用类型
    Employee.prototype.sayHello=function () {
        alert('hello:'+this.name);
    }*/


    Employee.prototype = {
        name:"dd",
        roles:[],
        sayHello:function () {
            alert('hello:'+this.name);
        }
    }

    var emp1 = new Employee();
    var emp2 = new Employee();

    emp1.roles.push("manager");

    console.log(emp1.roles);
    console.log(emp2.roles);

    // emp1.sayHello();
    // emp2.sayHello();




</script>
</html>